package buttons.view;

import processing.core.PApplet;
import processing.core.PConstants;

public class V_VerticalDropDown extends V_DropDown
{  
  public V_VerticalDropDown(String n, float xWidth, float yHeight){
    super(n, xWidth, yHeight);
  }
  
  @Override
  public void display(PApplet p)
  {
    v_Options.setXLoc(this.getXLoc()+this.getXSize());
    v_Options.setYLoc(this.getYLoc());
    
    if(visible)
    { 
      int tmpColor = p.color(p.red(bgColor)+offset, p.green(bgColor)+offset, p.blue(bgColor)+offset, transp); 
      p.stroke(0,0,0,transp);
      p.fill(tmpColor);    
      p.rect(xLoc, yLoc, xSize, ySize);
      p.textFont(B_Font);
      p.fill(0,0,0,transp); 
      
      p.pushMatrix();
      	p.translate(xLoc+fontSize, yLoc+ySize-2);
      	p.rotate(-PConstants.HALF_PI);
      	p.text(curOption,0,0);
      p.popMatrix();
      if(showName){
    	p.pushMatrix();
    	  p.translate(xLoc+fontSize, yLoc+ySize+p.textWidth(name)+5);
    	  p.rotate(-PConstants.HALF_PI);
    	  p.text(name, 0, 0);
    	p.popMatrix();
      }
      
      p.fill(200,200,200,transp-100);
      
      float maxH = Math.min(ySize/5, 14);
      p.rect(xLoc, yLoc, xSize, maxH);
      p.fill(0,0,0,transp); 
      p.triangle(xLoc+3.5f, yLoc+2,       xLoc+3.5f, yLoc+(maxH)-2,      xLoc+xSize-3.5f, yLoc+(maxH/2));
      v_Options.display(p); // Call to draw the expanded menu (it will only draw if set to be visible)
    }
  }
}
